package com.hilin.hilinim.netty.ws;

import com.hilin.common.util.IdUtils;
import com.hilin.entity.po.AccountInfoPo;
import io.netty.buffer.ByteBuf;
import io.netty.channel.Channel;
import io.netty.handler.codec.http.FullHttpRequest;
import lombok.extern.slf4j.Slf4j;

@Slf4j
public final class DefaultWsHandler implements IWsHandler {
    @Override
    public AccountInfoPo handshake(FullHttpRequest request, Channel channel) {
        return AccountInfoPo.builder()
                .orgId(IdUtils.DEFAULT.gen())
                .account(IdUtils.DEFAULT.gen())
                .build();
    }

    @Override
    public void afterHandshake(AccountInfoPo user, Channel channel) {

    }

    @Override
    public String onMsg(AccountInfoPo user, String msg, Channel channel) {
        log.info("收到消息:{}", msg);
        return null;
    }

    @Override
    public ByteBuf onMsg(AccountInfoPo user, ByteBuf msg, Channel channel) {
        log.info("收到二进制消息");
        return null;
    }

    @Override
    public void onMsg(AccountInfoPo user, Channel channel) {

    }

    @Override
    public void close(AccountInfoPo user, String reason, Channel channel) {

    }
}
